#include <bits/stdc++.h>
#define __gcd() gcd()
#define C int(3e5+7)
#define M int(1e9+7)
#define el '\n'
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
unordered_map<int,set<int> > mp;//value,idxs of this value
vector< array<int,2> > org;//id,value
int check[C];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
// freopen("convention2.in","r",stdin);
// freopen("convention2.out","w",stdout);
int n,m;
cin>>n>>m;
org.push_back({0,0});
int cur_id = 1,cur_noti = 0;
for(int i=1;i <= m;i++){
int t,x;
cin>>t>>x;
if(t == 1){
mp[x].insert(i);
org.push_back({i,x});
cur_noti++;
}
else if(t == 2){
for(auto it:mp[x]){
if(!check[it]){
cur_noti--;
check[it] = 1;
}
}
mp[x].clear();
}
else {
for(int k = cur_id; k <= x; k++){
if(!check[org[k][0]]){
cur_noti--;
mp[org[k][1]].erase(org[k][0]);
check[org[k][0]] = 1;
}
}
cur_id = max(cur_id,x + 1);
}
cout<<cur_noti<<el;
}
}
660A - Co-prime Array | 1692F - 3SUM |
1470A - Strange Birthday Party | 190D - Non-Secret Cypher |
1721B - Deadly Laser | 1721C - Min-Max Array Transformation |
1721A - Image | 1180C - Valeriy and Deque |
557A - Ilya and Diplomas | 1037D - Valid BFS |
1144F - Graph Without Long Directed Paths | 1228A - Distinct Digits |
355B - Vasya and Public Transport | 1230A - Dawid and Bags of Candies |
1530A - Binary Decimal | 1472D - Even-Odd Game |
441C - Valera and Tubes | 1328E - Tree Queries |
265A - Colorful Stones (Simplified Edition) | 296A - Yaroslav and Permutations |
967B - Watering System | 152A - Marks |
1398A - Bad Triangle | 137A - Postcards and photos |
1674D - A-B-C Sort | 334A - Candy Bags |
855A - Tom Riddle's Diary | 1417A - Copy-paste |
1038A - Equality | 1061A - Coins |